package com.mrroman.linksender.sender;

import java.io.Serializable;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Message implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -5768244745712783468L;
    private String sender;
    private Date date;
    private String message;
    private int flags;
    transient InetAddress addressOfSender;
    public final static int MESSAGE_FLAG_HIDDEN = 1;
    public final static int MESSAGE_FLAG_PRIVATE = 2;
    public final static int MESSAGE_FLAG_SELF = 4;

    public Message() {
        this(null, null);
    }

    public Message(String sender, String message) {
        this(sender, new Date(), message);
    }

    public Message(String sender, Date date, String message) {
        this(sender, date, message, 0);
    }

    public Message(String sender, Date date, String message, int flags) {
        this.sender = sender;
        this.message = message;
        this.date = date;
        this.flags = flags;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getFlags() {
        return flags;
    }

    public void setFlags(int flags) {
        this.flags = flags;
    }

    public InetAddress getAddressOfSender() {
        return addressOfSender;
    }

    public void setAddressOfSender(InetAddress addressOfSender) {
        this.addressOfSender = addressOfSender;
    }

    @Override
    public String toString() {
        return sender + "@" + SimpleDateFormat.getDateTimeInstance().format(date) + ": " + message;
    }
}
